import re
project_code = {
    "1-76项目": 1,
    "2-76派工单": 2,
    "3-80项目": 3,
    "4-80项目机加": 4,
    "5-80派工单": 5,
    "6-819项目": 6,
    "7-819机加、派工单项目": 7,
    "8-CC腹鳍项目": 8,
    "9-CC腹鳍机加派工单项目": 9,
    "10-E-尾翼项目": 10,
    "11-FY-胶结件": 11,
    "12-FY-胶结件随炉件": 12,
    "13-FY-小肋": 13,
    "14-FY-蒙皮": 14,
    "15-FY-蒙皮随炉件": 15,
    "16-FY-后梁随炉件": 16,
    "17-FY-小肋随炉件": 17,
    "18-FY-边肋随炉件": 18,
    "19-FY-后梁": 19,
    "20-FY-垫块": 20,
    "21-FY-历史机加": 21,
    "22-FY项目机加": 22,
    "23-FY-整流罩": 23,
    "24-FY-整流罩随炉件": 24,
    "25-FY-封边肋": 25,
    "26-FY-隐身罩": 26,
    "27-FY-派工单及返修": 27,
    "28-历史FY打包": 28,
    "29-特殊过程变更再确认典型件": 29,
    "30-FY-层压板5429": 30,
    "31-FY-层压板9611": 31,
    "32-GS": 32,
    "33-LS": 33,
    "34-LS-派工单": 34,
    "35-LS-机加": 35,
    "36-TTX-133天线项目": 36,
    "37-金属电磁微项目": 37,
    "38-其他": 38,
    "39-3.0项目": 39,
    "40-GS工艺过程卡片转厂": 40,
    "41-QJ项目": 41,
    "42-FJ": 42,
    "43-来料检验": 43,
    "44-A5": 44
}


def get_fo_number(project, file_number_old):
    # 获取项目代码并格式化为至少3位，确保不足的地方补零
    project_code_formatted = f"{project_code.get(project):>03}"

    # 格式化文件编号为至少5位，去除非数字字符并补零
    try:
        cleaned_number = re.sub(r'\D', '', str(file_number_old))  # 提取数字
        file_number_formatted = f"{int(cleaned_number):05}" if cleaned_number else "00000"
    except ValueError:
        file_number_formatted = "00000"

    # 拼接结果
    return f"FO-{project_code_formatted}-{file_number_formatted}"

if __name__ == '__main__':
   print(get_fo_number("3-80项目","6306"))
